﻿using System;
using System.Collections.Generic;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x02000DBA RID: 3514
	internal class XCutScene : XSingleton<XCutScene>
	{
		// Token: 0x17003355 RID: 13141
		// (get) Token: 0x0600BE6A RID: 48746 RVA: 0x0027B420 File Offset: 0x00279620
		public bool IsPlaying
		{
			get
			{
				return this._cut_scene;
			}
		}

		// Token: 0x17003356 RID: 13142
		// (get) Token: 0x0600BE6B RID: 48747 RVA: 0x0027B438 File Offset: 0x00279638
		// (set) Token: 0x0600BE6C RID: 48748 RVA: 0x0027B450 File Offset: 0x00279650
		public bool IsExcludeNewBorn
		{
			get
			{
				return this._exclusive;
			}
			set
			{
				this._exclusive = value;
			}
		}

		// Token: 0x17003357 RID: 13143
		// (get) Token: 0x0600BE6D RID: 48749 RVA: 0x0027B45C File Offset: 0x0027965C
		public float Length
		{
			get
			{
				return this.IsPlaying ? this._cut_scene_data.Length : 0f;
			}
		}

		// Token: 0x17003358 RID: 13144
		// (get) Token: 0x0600BE6E RID: 48750 RVA: 0x0027B488 File Offset: 0x00279688
		public string Name
		{
			get
			{
				return this._name;
			}
		}

		// Token: 0x17003359 RID: 13145
		// (get) Token: 0x0600BE6F RID: 48751 RVA: 0x0027B4A0 File Offset: 0x002796A0
		// (set) Token: 0x0600BE70 RID: 48752 RVA: 0x0027B4A8 File Offset: 0x002796A8
		public Vector3 EndWithPos { get; set; }

		// Token: 0x1700335A RID: 13146
		// (get) Token: 0x0600BE71 RID: 48753 RVA: 0x0027B4B1 File Offset: 0x002796B1
		// (set) Token: 0x0600BE72 RID: 48754 RVA: 0x0027B4B9 File Offset: 0x002796B9
		public float EndWithDir { get; set; }

		// Token: 0x1700335B RID: 13147
		// (get) Token: 0x0600BE73 RID: 48755 RVA: 0x0027B4C2 File Offset: 0x002796C2
		// (set) Token: 0x0600BE74 RID: 48756 RVA: 0x0027B4CA File Offset: 0x002796CA
		public uint GeneralMonsterID { get; set; }

		// Token: 0x0600BE75 RID: 48757 RVA: 0x0027B4D4 File Offset: 0x002796D4
		public XCutScene()
		{
			this._camera.AutoSync_At_Begin = false;
			this._camera.Coordinate = CameraMotionSpace.World;
			this._camera.Follow_Position = false;
			this._camera.LookAt_Target = false;
			this._camera.At = 0f;
			this._camera.MotionType = CameraMotionType.AnchorBased;
			this._startCb = new XTimerMgr.ElapsedEventHandler(this.InnerStart);
			this._endCb = new XTimerMgr.ElapsedEventHandler(this.InnerEnd);
			this._actorOnStageCb = new XTimerMgr.ElapsedEventHandler(this.ActorOnStage);
			this._playerOnStageCb = new XTimerMgr.ElapsedEventHandler(this.PlayerOnStage);
			this._fxCb = new XTimerMgr.ElapsedEventHandler(this.Fx);
			this._audioCb = new XTimerMgr.ElapsedEventHandler(this.Audio);
			this._subTitleCb = new XTimerMgr.ElapsedEventHandler(this.SubTitle);
			this._slashCb = new XTimerMgr.ElapsedEventHandler(this.Slash);
			this._endShowCb = new XTimerMgr.ElapsedEventHandler(this.EndShow);
			this._endSubTitleCb = new XTimerMgr.ElapsedEventHandler(this.EndSubTitle);
			this._findFxTransCb = new CommandCallback(this.AttachFx);
		}

		// Token: 0x0600BE76 RID: 48758 RVA: 0x0027B6C4 File Offset: 0x002798C4
		public void Start(string cutname, bool bFadeOut = true, bool bFadeAtEnd = true)
		{
			//bool cut_scene = this._cut_scene;
			XSingleton<XDebug>.singleton.AddLog("XCutScene.Start --------------------: " + cutname, null, null, null, null, null);
			if (this._cut_scene)
			{
				this.Stop(true);
			}
			this._bFadeAtEnd = bFadeAtEnd;
			this._actors = new List<XActor>();
			XSingleton<XAudioMgr>.singleton.StopSoundForCutscene();
			XSingleton<XOperationRecord>.singleton.DoScriptRecord(cutname);
			XSingleton<XPostEffectMgr>.singleton.MakeEffectEnable(XPostEffect.BlackWhite, false);
			this._cut_scene = true;
			this._name = cutname;
			this._cut_scene_data = XSingleton<XResourceLoaderMgr>.singleton.GetData<XCutSceneData>(this._name, ".txt");
			XBillBoardDocument.SetAllBillBoardState(BillBoardHideType.CutScene, false);
			//bool flag = XSingleton<XGame>.singleton.CurrentStage is XConcreteStage;
			if (XSingleton<XGame>.singleton.CurrentStage is XConcreteStage)
			{
				XSingleton<XGameUI>.singleton.ShowBlock(true);
			}
			//bool overrideBGM = this._cut_scene_data.OverrideBGM;
			if (this._cut_scene_data.OverrideBGM)
			{
				XSingleton<XScene>.singleton.PauseBGM();
			}
			//bool flag2 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded();
			if (DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded())
			{
				DlgBase<BattleMain, BattleMainBehaviour>.singleton.OnStopVoiceRecord();
			}
			//bool flag3 = DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.IsLoaded();
			//zcg 
// 			if (DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.IsLoaded())
// 			{
// 				DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.OnStopVoiceRecord();
// 			}
			XSingleton<XShell>.singleton.TimeMagicBack();
			XSingleton<XAIGeneralMgr>.singleton.EnablePlayerAI(false);
			List<XEntity> ally = XSingleton<XEntityMgr>.singleton.GetAlly(XSingleton<XEntityMgr>.singleton.Player);
			for (int i = 0; i < ally.Count; i++)
			{
				//bool flag4 = ally[i] != XSingleton<XEntityMgr>.singleton.Player;
				if (ally[i] != XSingleton<XEntityMgr>.singleton.Player)
				{
					XAIEnableAI @event = XEventPool<XAIEnableAI>.GetEvent();
					@event.Firer = ally[i];
					@event.Enable = false;
					XSingleton<XEventMgr>.singleton.FireEvent(@event);
				}
			}
			//bool flag5 = string.IsNullOrEmpty(this._cut_scene_data.CameraClip);
			if (string.IsNullOrEmpty(this._cut_scene_data.CameraClip))
			{
				XAutoFade.FadeOut2In(1f, 2.5f);
				this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(1f, this._endCb, null));
			}
			else if (bFadeOut)
			{
				XAutoFade.FadeOut2In(0.5f, 0.5f);
				this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(0.5f, this._startCb, null));
			}
			else
			{
				this.InnerStart(this);
			}
		}

		// Token: 0x0600BE77 RID: 48759 RVA: 0x0027B8E4 File Offset: 0x00279AE4
		public void Stop(bool bImmdiately = false)
		{
			//bool isPlaying = this.IsPlaying;
			if (this.IsPlaying)
			{
				for (int i = 0; i < this._eventToken.Count; i++)
				{
					XSingleton<XTimerMgr>.singleton.KillTimer(this._eventToken[i]);
				}
				this._eventToken.Clear();
				if (bImmdiately)
				{
					this.InnerEnd(null);
				}
				else
				{
					this.EndShow(null);
				}
			}
		}

		// Token: 0x0600BE78 RID: 48760 RVA: 0x0027B954 File Offset: 0x00279B54
		public void ClearCommon()
		{
			for (int i = 0; i < this._common_fx.Count; i++)
			{
				//bool flag = this._common_fx[i] != null;
				if (this._common_fx[i] != null)
				{
					XSingleton<XFxMgr>.singleton.DestroyFx(this._common_fx[i], true);
				}
			}
			this._common_fx.Clear();
			foreach (XActor xactor in this._common_actors.Values)
			{
				xactor.Uninitilize();
			}
			this._common_actors.Clear();
		}

		// Token: 0x0600BE79 RID: 48761 RVA: 0x0027BA14 File Offset: 0x00279C14
		public void OnLeaveScene()
		{
			//bool isPlaying = this.IsPlaying;
			if (this.IsPlaying)
			{
				this.Stop(true);
				XAutoFade.FastFadeIn();
			}
		}

		// Token: 0x0600BE7A RID: 48762 RVA: 0x0027BA3C File Offset: 0x00279C3C
		public void AddedTimerToken(uint token)
		{
			this._eventToken.Add(token);
		}

		// Token: 0x0600BE7B RID: 48763 RVA: 0x0027BA4C File Offset: 0x00279C4C
		private void InnerStart(object o)
		{
			XSingleton<XDebug>.singleton.AddLog("InnerStart!");
			XSingleton<XInput>.singleton.Freezed = true;
			//bool flag = o == null;
			if (o == null)
			{
				XAutoFade.MakeBlack(false);
			}
			this.farClipPlaneBackUP = XSingleton<XScene>.singleton.GameCamera.UnityCamera.farClipPlane;
			XSingleton<XScene>.singleton.GameCamera.UnityCamera.farClipPlane = 150f;
			XSingleton<XScene>.singleton.GameCamera.UnityCamera.fieldOfView = this._cut_scene_data.FieldOfView;
			this._camera.Motion = this._cut_scene_data.CameraClip;
			this._camera.Follow_Position = this._cut_scene_data.GeneralShow;
			this._camera.AutoSync_At_Begin = this._cut_scene_data.GeneralShow;
			//bool flag2 = XSingleton<XScene>.singleton.GameCamera.CloseUp != null;
			if (XSingleton<XScene>.singleton.GameCamera.CloseUp != null)
			{
				XSingleton<XScene>.singleton.GameCamera.CloseUp.Stop(null);
			}
			//bool flag3 = XSingleton<XScene>.singleton.GameCamera.Collision != null;
			if (XSingleton<XScene>.singleton.GameCamera.Collision != null)
			{
				XSingleton<XScene>.singleton.GameCamera.Collision.Enabled = false;
			}
			//bool flag4 = XSingleton<XScene>.singleton.GameCamera.VAdjust != null;
			if (XSingleton<XScene>.singleton.GameCamera.VAdjust != null)
			{
				XSingleton<XScene>.singleton.GameCamera.VAdjust.Enabled = false;
			}
			//bool flag5 = XSingleton<XScene>.singleton.GameCamera.Solo != null;
			if (XSingleton<XScene>.singleton.GameCamera.Solo != null)
			{
				XSingleton<XScene>.singleton.GameCamera.Solo.Stop();
			}
			foreach (XActorDataClip xactorDataClip in this._cut_scene_data.Actors)
			{
				this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(xactorDataClip.TimeLineAt / 30f - 0.016f, this._actorOnStageCb, xactorDataClip));
			}
			//bool generalShow = this._cut_scene_data.GeneralShow;
			if (this._cut_scene_data.GeneralShow)
			{
				//bool flag6 = XSingleton<XEntityMgr>.singleton.Boss != null;
				if (XSingleton<XEntityMgr>.singleton.Boss != null)
				{
					this._target = XSingleton<XEntityMgr>.singleton.Boss;
				}
				else
				{
					//bool flag7 = this.GeneralMonsterID > 0U;
					if (this.GeneralMonsterID > 0U)
					{
						Vector3 zero = Vector3.zero;
						float angle = 0f;
						//bool flag8 = XSingleton<XLevelSpawnMgr>.singleton.QueryMonsterStaticInfo(this.GeneralMonsterID, ref zero, ref angle);
						if (XSingleton<XLevelSpawnMgr>.singleton.QueryMonsterStaticInfo(this.GeneralMonsterID, ref zero, ref angle))
						{
							this._target = XSingleton<XEntityMgr>.singleton.CreateDummy(this.GeneralMonsterID, zero, XSingleton<XCommon>.singleton.FloatToQuaternion(angle));
						}
						else
						{
							XSingleton<XDebug>.singleton.AddErrorLog("QueryMonsterStaticInfo failed with id ", this.GeneralMonsterID.ToString(), " in cutscene ", this._cut_scene_data.Name, null, null);
						}
					}
					else
					{
						XSingleton<XDebug>.singleton.AddErrorLog("Missing Boss id in general cutscene script with name ", this._cut_scene_data.Name, null, null, null, null);
					}
				}
			}
			XCameraMotionEventArgs @event = XEventPool<XCameraMotionEventArgs>.GetEvent();
			@event.Motion = this._camera;
			@event.Target = this._target;
			@event.Trigger = this._cut_scene_data.Trigger;
			@event.Firer = XSingleton<XScene>.singleton.GameCamera;
			XSingleton<XEventMgr>.singleton.FireEvent(@event);
			//bool flag9 = !this._cut_scene_data.GeneralShow;
			if (!this._cut_scene_data.GeneralShow)
			{
				foreach (XPlayerDataClip xplayerDataClip in this._cut_scene_data.Player)
				{
					this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(xplayerDataClip.TimeLineAt / 30f - 0.016f, this._playerOnStageCb, xplayerDataClip));
				}
				foreach (XFxDataClip xfxDataClip in this._cut_scene_data.Fxs)
				{
					this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(xfxDataClip.TimeLineAt / 30f, this._fxCb, xfxDataClip));
				}
			}
			foreach (XAudioDataClip xaudioDataClip in this._cut_scene_data.Audios)
			{
				this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(xaudioDataClip.TimeLineAt / 30f, this._audioCb, xaudioDataClip));
			}
			//bool mourningborder = this._cut_scene_data.Mourningborder;
			if (this._cut_scene_data.Mourningborder)
			{
				DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetVisible(true, true);
				foreach (XSubTitleDataClip xsubTitleDataClip in this._cut_scene_data.SubTitle)
				{
					this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(xsubTitleDataClip.TimeLineAt / 30f, this._subTitleCb, xsubTitleDataClip));
				}
				foreach (XSlashDataClip xslashDataClip in this._cut_scene_data.Slash)
				{
					this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(xslashDataClip.TimeLineAt / 30f, new XTimerMgr.ElapsedEventHandler(this.Slash), xslashDataClip));
				}
			}
			else
			{
				//bool flag10 = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World;
				if (XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World)
				{
				}
			}
			//bool autoEnd = this._cut_scene_data.AutoEnd;
			if (this._cut_scene_data.AutoEnd)
			{
				this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer((this._cut_scene_data.TotalFrame - 30f) / 30f, this._endShowCb, null));
			}
			this.Reflection();
			XSingleton<XEntityMgr>.singleton.Dummilize(this._cut_scene_data.TypeMask);
			//bool flag11 = this.EndWithPos.sqrMagnitude > 0.1f;
			if (this.EndWithPos.sqrMagnitude > 0.1f)
			{
				this.CorrectToEndPos();
			}
		}

		// Token: 0x0600BE7C RID: 48764 RVA: 0x0027C078 File Offset: 0x0027A278
		public void Reflection()
		{
			//bool flag = this._cut_scene_data != null;
			if (this._cut_scene_data != null)
			{
				//bool flag2 = !string.IsNullOrEmpty(this._cut_scene_data.Script);
				if (!string.IsNullOrEmpty(this._cut_scene_data.Script))
				{
					XSingleton<ScriptCode>.singleton.ExecuteCutScene(this._cut_scene_data.Script, this._actors);
				}
			}
		}

		// Token: 0x0600BE7D RID: 48765 RVA: 0x0027C0CC File Offset: 0x0027A2CC
		private void ActorOnStage(object o)
		{
			XSingleton<XDebug>.singleton.AddLog("ActorOnStage!");
			XActorDataClip xactorDataClip = o as XActorDataClip;
			XActor xactor = null;
			//bool flag = !string.IsNullOrEmpty(xactorDataClip.Tag);
			if (!string.IsNullOrEmpty(xactorDataClip.Tag))
			{
				int num;
				//bool flag2 = int.TryParse(xactorDataClip.Tag, out num) && num > XGame.RoleCount;
				if (int.TryParse(xactorDataClip.Tag, out num) && num > XGame.RoleCount)
				{
					return;
				}
			}
			Vector3 pos = new Vector3(xactorDataClip.AppearX, xactorDataClip.AppearY, xactorDataClip.AppearZ);
			//bool flag3 = xactorDataClip.bUsingID && xactorDataClip.bToCommonPool;
			if (xactorDataClip.bUsingID && xactorDataClip.bToCommonPool)
			{
				//bool flag4 = !this._common_actors.TryGetValue((uint)xactorDataClip.StatisticsID, out xactor);
				if (!this._common_actors.TryGetValue((uint)xactorDataClip.StatisticsID, out xactor))
				{
					xactor = new XActor((uint)xactorDataClip.StatisticsID, pos, xactorDataClip.Clip);
					xactor.Initilize(0);
					//bool flag5 = !string.IsNullOrEmpty(xactorDataClip.Tag);
					if (!string.IsNullOrEmpty(xactorDataClip.Tag))
					{
						xactor.EngineObject.Tag = xactorDataClip.Tag;
					}
					this._common_actors.Add((uint)xactorDataClip.StatisticsID, xactor);
				}
				else
				{
					xactor.PlayAnimation(xactorDataClip.Clip);
				}
			}
			else
			{
				xactor = (xactorDataClip.bUsingID ? new XActor((uint)xactorDataClip.StatisticsID, pos, xactorDataClip.Clip) : new XActor(xactorDataClip.Prefab, pos, Quaternion.identity, xactorDataClip.Clip));
				xactor.Initilize(0);
			}
			this._actors.Add(xactor);
			this.Reflection();
		}

		// Token: 0x0600BE7E RID: 48766 RVA: 0x0027C250 File Offset: 0x0027A450
		private void PlayerOnStage(object o)
		{
			XPlayerDataClip xplayerDataClip = o as XPlayerDataClip;
			Vector3 pos = new Vector3(xplayerDataClip.AppearX, xplayerDataClip.AppearY, xplayerDataClip.AppearZ);
			XActor xactor;
			switch (XSingleton<XEntityMgr>.singleton.Player.BasicTypeID)
			{
			case 1U:
				xactor = new XActor(pos, xplayerDataClip.Clip1);
				break;
			case 2U:
				xactor = new XActor(pos, xplayerDataClip.Clip2);
				break;
			case 3U:
				xactor = new XActor(pos, xplayerDataClip.Clip3);
				break;
			case 4U:
				xactor = new XActor(pos, xplayerDataClip.Clip4);
				break;
			case 5U:
				xactor = new XActor(pos, xplayerDataClip.Clip5);
				break;
			case 6U:
				xactor = new XActor(pos, xplayerDataClip.Clip6);
				break;
			case 7U:
				xactor = new XActor(pos, xplayerDataClip.Clip7);
				break;
			default:
				xactor = new XActor(pos, null);
				break;
			}
			xactor.Initilize(0);
			this._actors.Add(xactor);
			this.Reflection();
		}

		// Token: 0x0600BE7F RID: 48767 RVA: 0x0027C348 File Offset: 0x0027A548
		private void AttachFx(XGameObject go, object o, int commandID)
		{
			XFxDataClip xfxDataClip = o as XFxDataClip;
			XFx xfx = XSingleton<XFxMgr>.singleton.CreateFx(xfxDataClip.Fx, null, false);
			xfx.DelayDestroy = xfxDataClip.Destroy_Delay;
			Transform transform = (go != null) ? go.Find(xfxDataClip.Bone) : null;
			//bool flag = transform != null;
			if (transform != null)
			{
				xfx.Play(transform, Vector3.zero, xfxDataClip.Scale * Vector3.one, 1f, xfxDataClip.Follow, false);
				//bool flag2 = this._common_actors.ContainsValue(this._actors[xfxDataClip.BindIdx]);
				if (this._common_actors.ContainsValue(this._actors[xfxDataClip.BindIdx]))
				{
					this._common_fx.Add(xfx);
				}
			}
			else
			{
				xfx.Play(new Vector3(xfxDataClip.AppearX, xfxDataClip.AppearY, xfxDataClip.AppearZ), XSingleton<XCommon>.singleton.FloatToQuaternion(xfxDataClip.Face), Vector3.one, 1f);
			}
			this._fx.Add(xfx);
		}

		// Token: 0x0600BE80 RID: 48768 RVA: 0x0027C43C File Offset: 0x0027A63C
		private void Fx(object o)
		{
			XFxDataClip xfxDataClip = o as XFxDataClip;
			//bool flag = xfxDataClip.BindIdx >= 0;
			if (xfxDataClip.BindIdx >= 0)
			{
				XGameObject engineObject = this._actors[xfxDataClip.BindIdx].EngineObject;
				engineObject.CallCommand(this._findFxTransCb, o, -1, false);
			}
			else
			{
				this.AttachFx(null, o, -1);
			}
		}

		// Token: 0x0600BE81 RID: 48769 RVA: 0x0027C498 File Offset: 0x0027A698
		private void Audio(object o)
		{
			XAudioDataClip xaudioDataClip = o as XAudioDataClip;
			//bool flag = xaudioDataClip.BindIdx < 0;
			if (xaudioDataClip.BindIdx < 0)
			{
				XSingleton<XAudioMgr>.singleton.PlayUISound(xaudioDataClip.Clip, true, xaudioDataClip.Channel);
			}
			else
			{
				//bool flag2 = XSingleton<XEntityMgr>.singleton.Player != null;
				if (XSingleton<XEntityMgr>.singleton.Player != null)
				{
					XSingleton<XAudioMgr>.singleton.PlaySound(this._actors[xaudioDataClip.BindIdx], xaudioDataClip.Channel, xaudioDataClip.Clip, false, new XAudioExParam("PlayerClass", XSingleton<XEntityMgr>.singleton.Player.PlayerAttributes.BasicTypeID));
				}
				else
				{
					XSingleton<XAudioMgr>.singleton.PlaySound(this._actors[xaudioDataClip.BindIdx], xaudioDataClip.Channel, xaudioDataClip.Clip);
				}
			}
		}

		// Token: 0x0600BE82 RID: 48770 RVA: 0x0027C564 File Offset: 0x0027A764
		private void SubTitle(object o)
		{
			XSubTitleDataClip xsubTitleDataClip = o as XSubTitleDataClip;
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetText(xsubTitleDataClip.Context);
			XSingleton<XTimerMgr>.singleton.KillTimer(this._token);
			this._token = XSingleton<XTimerMgr>.singleton.SetTimer(xsubTitleDataClip.Duration / 30f, this._endSubTitleCb, null);
		}

		// Token: 0x0600BE83 RID: 48771 RVA: 0x0027C5C0 File Offset: 0x0027A7C0
		private void Slash(object o)
		{
			XSlashDataClip xslashDataClip = o as XSlashDataClip;
			//bool generalShow = this._cut_scene_data.GeneralShow;
			if (this._cut_scene_data.GeneralShow)
			{
				string name = "";
				//bool flag = this._target != null && (this._target.IsDummy || XEntity.ValideEntity(this._target));
				if (this._target != null && (this._target.IsDummy || XEntity.ValideEntity(this._target)))
				{
					XEntityStatistics.RowData byID = XSingleton<XEntityMgr>.singleton.EntityStatistics.GetByID(this._target.TypeID);
					//bool flag2 = byID != null;
					if (byID != null)
					{
						name = byID.Name;
					}
				}
				DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetIntroText(true, name, xslashDataClip.Discription, xslashDataClip.AnchorX, xslashDataClip.AnchorY);
			}
			else
			{
				DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetIntroText(true, xslashDataClip.Name, xslashDataClip.Discription, xslashDataClip.AnchorX, xslashDataClip.AnchorY);
			}
			this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(xslashDataClip.Duration, new XTimerMgr.ElapsedEventHandler(this.EndSlash), null));
		}

		// Token: 0x0600BE84 RID: 48772 RVA: 0x0027C6B4 File Offset: 0x0027A8B4
		private void EndShow(object o)
		{
			//bool bFadeAtEnd = this._bFadeAtEnd;
			if (this._bFadeAtEnd)
			{
				XAutoFade.FadeOut2In(1f, 1f);
			}
			this.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(0.984f, this._endCb, null));
		}

		// Token: 0x0600BE85 RID: 48773 RVA: 0x0027C6FB File Offset: 0x0027A8FB
		private void EndSlash(object o)
		{
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetIntroText(false, "", "", 0f, 0f);
		}

		// Token: 0x0600BE86 RID: 48774 RVA: 0x0027C71E File Offset: 0x0027A91E
		private void EndSubTitle(object o)
		{
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetText("");
		}

		// Token: 0x0600BE87 RID: 48775 RVA: 0x0027C734 File Offset: 0x0027A934
		private void InnerEnd(object o)
		{
			//bool overrideBGM = this._cut_scene_data.OverrideBGM;
			if (this._cut_scene_data.OverrideBGM)
			{
				XSingleton<XScene>.singleton.ResumeBGM();
			}
			XSingleton<XTimerMgr>.singleton.KillTimer(this._token);
			for (int i = 0; i < this._eventToken.Count; i++)
			{
				XSingleton<XTimerMgr>.singleton.KillTimer(this._eventToken[i]);
			}
			this._eventToken.Clear();
			XBillBoardDocument.SetAllBillBoardState(BillBoardHideType.CutScene, true);
			for (int j = 0; j < this._fx.Count; j++)
			{
				//bool flag = !this._common_fx.Contains(this._fx[j]);
				if (!this._common_fx.Contains(this._fx[j]))
				{
					XSingleton<XFxMgr>.singleton.DestroyFx(this._fx[j], true);
				}
			}
			this._fx.Clear();
			for (int k = 0; k < this._actors.Count; k++)
			{
				//bool flag2 = !this._common_actors.ContainsValue(this._actors[k]);
				if (!this._common_actors.ContainsValue(this._actors[k]))
				{
					this._actors[k].Uninitilize();
				}
			}
			this._actors.Clear();
			this._actors = null;
			XSingleton<XScene>.singleton.GameCamera.FovBack();
			this._cut_scene = false;
			this._name = null;
			XSingleton<XEntityMgr>.singleton.Dedummilize();
			this.Reflection();
			//bool mourningborder = this._cut_scene_data.Mourningborder;
			if (this._cut_scene_data.Mourningborder)
			{
				this.EndSubTitle(null);
				DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetVisible(false, true);
				XSingleton<XPostEffectMgr>.singleton.MakeEffectEnable(XPostEffect.BlackWhite, XSingleton<XEntityMgr>.singleton.Player.IsDead);
			}
			//bool flag3 = !string.IsNullOrEmpty(this._cut_scene_data.CameraClip);
			if (!string.IsNullOrEmpty(this._cut_scene_data.CameraClip))
			{
				XCameraMotionEndEventArgs @event = XEventPool<XCameraMotionEndEventArgs>.GetEvent();
				@event.Target = this._target;
				@event.Firer = XSingleton<XScene>.singleton.GameCamera;
				@event.CutSceneEnd = true;
				XSingleton<XEventMgr>.singleton.FireEvent(@event);
			}
			//bool flag4 = this._target != null && this._target.IsDummy;
			if (this._target != null && this._target.IsDummy)
			{
				XSingleton<XEntityMgr>.singleton.DestroyImmediate(this._target);
			}
			this._target = null;
			XSingleton<XInput>.singleton.Freezed = false;
			//bool flag5 = XSingleton<XGame>.singleton.CurrentStage is XConcreteStage;
			if (XSingleton<XGame>.singleton.CurrentStage is XConcreteStage)
			{
				XSingleton<XGameUI>.singleton.ShowBlock(false);
			}
			//bool flag6 = XSingleton<XEntityMgr>.singleton.Player != null && !XSingleton<XLevelFinishMgr>.singleton.IsCurrentLevelFinished;
			if (XSingleton<XEntityMgr>.singleton.Player != null && !XSingleton<XLevelFinishMgr>.singleton.IsCurrentLevelFinished)
			{
				XSingleton<XAIGeneralMgr>.singleton.EnablePlayerAI(true);
				List<XEntity> ally = XSingleton<XEntityMgr>.singleton.GetAlly(XSingleton<XEntityMgr>.singleton.Player);
				for (int l = 0; l < ally.Count; l++)
				{
					//bool flag7 = ally[l] != XSingleton<XEntityMgr>.singleton.Player;
					if (ally[l] != XSingleton<XEntityMgr>.singleton.Player)
					{
						XAIEnableAI event2 = XEventPool<XAIEnableAI>.GetEvent();
						event2.Firer = ally[l];
						event2.Enable = true;
						XSingleton<XEventMgr>.singleton.FireEvent(event2);
					}
				}
			}
			XSingleton<XScene>.singleton.GameCamera.TrySolo();
			this.EndWithPos = Vector3.zero;
			this.GeneralMonsterID = 0U;
			XSingleton<XScene>.singleton.GameCamera.UnityCamera.farClipPlane = this.farClipPlaneBackUP;
			//bool flag8 = !XSingleton<XGame>.singleton.SyncMode && !XOperationData.Is3DMode() && XEntity.ValideEntity(XSingleton<XEntityMgr>.singleton.Player);
			if (!XSingleton<XGame>.singleton.SyncMode && !XOperationData.Is3DMode() && XEntity.ValideEntity(XSingleton<XEntityMgr>.singleton.Player))
			{
				XSingleton<XScene>.singleton.GameCamera.Root_R_Y = XSingleton<XCommon>.singleton.AngleToFloat(XSingleton<XEntityMgr>.singleton.Player.MoveObj.Forward);
			}
			//bool flag9 = DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible();
			if (DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible())
			{
				DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.RefreshWelcomeBackFlow();
			}
		}

		// Token: 0x0600BE88 RID: 48776 RVA: 0x0027CB18 File Offset: 0x0027AD18
		private void CorrectToEndPos()
		{
			//bool syncMode = XSingleton<XGame>.singleton.SyncMode;
			if (!XSingleton<XGame>.singleton.SyncMode)
			{
				List<XEntity> ally = XSingleton<XEntityMgr>.singleton.GetAlly(XSingleton<XEntityMgr>.singleton.Player);
				for (int i = 0; i < ally.Count; i++)
				{
					//bool flag = ally[i].IsRole || (ally[i].MobbedBy != null && ally[i].MobbedBy.IsRole && ally[i].Attributes != null && ally[i].Attributes.RunSpeed > 0f);
					if (ally[i].IsRole || (ally[i].MobbedBy != null && ally[i].MobbedBy.IsRole && ally[i].Attributes != null && ally[i].Attributes.RunSpeed > 0f))
					{
						XOnEntityTransferEventArgs @event = XEventPool<XOnEntityTransferEventArgs>.GetEvent();
						@event.Firer = ally[i];
						XSingleton<XEventMgr>.singleton.FireEvent(@event);
						ally[i].CorrectMe(this.EndWithPos, XSingleton<XCommon>.singleton.FloatToAngle(this.EndWithDir), false, false);
					}
				}
			}
		}

		// Token: 0x04004DC5 RID: 19909
		public Dictionary<uint, XActor> _common_actors = new Dictionary<uint, XActor>();

		// Token: 0x04004DC6 RID: 19910
		private List<XFx> _common_fx = new List<XFx>();

		// Token: 0x04004DC7 RID: 19911
		private bool _cut_scene = false;

		// Token: 0x04004DC8 RID: 19912
		private bool _exclusive = true;

		// Token: 0x04004DC9 RID: 19913
		private List<uint> _eventToken = new List<uint>();

		// Token: 0x04004DCA RID: 19914
		private List<XActor> _actors = null;

		// Token: 0x04004DCB RID: 19915
		protected List<XFx> _fx = new List<XFx>();

		// Token: 0x04004DCC RID: 19916
		private XCutSceneData _cut_scene_data = null;

		// Token: 0x04004DCD RID: 19917
		private XCameraMotionData _camera = new XCameraMotionData();

		// Token: 0x04004DCE RID: 19918
		private XEntity _target = null;

		// Token: 0x04004DCF RID: 19919
		private uint _token = 0U;

		// Token: 0x04004DD0 RID: 19920
		private string _name = null;

		// Token: 0x04004DD1 RID: 19921
		private XTimerMgr.ElapsedEventHandler _startCb = null;

		// Token: 0x04004DD2 RID: 19922
		private XTimerMgr.ElapsedEventHandler _endCb = null;

		// Token: 0x04004DD3 RID: 19923
		private XTimerMgr.ElapsedEventHandler _actorOnStageCb = null;

		// Token: 0x04004DD4 RID: 19924
		private XTimerMgr.ElapsedEventHandler _playerOnStageCb = null;

		// Token: 0x04004DD5 RID: 19925
		private XTimerMgr.ElapsedEventHandler _fxCb = null;

		// Token: 0x04004DD6 RID: 19926
		private XTimerMgr.ElapsedEventHandler _audioCb = null;

		// Token: 0x04004DD7 RID: 19927
		private XTimerMgr.ElapsedEventHandler _subTitleCb = null;

		// Token: 0x04004DD8 RID: 19928
		private XTimerMgr.ElapsedEventHandler _slashCb = null;

		// Token: 0x04004DD9 RID: 19929
		private XTimerMgr.ElapsedEventHandler _endShowCb = null;

		// Token: 0x04004DDA RID: 19930
		private XTimerMgr.ElapsedEventHandler _endSubTitleCb = null;

		// Token: 0x04004DDB RID: 19931
		private CommandCallback _findFxTransCb = null;

		// Token: 0x04004DDC RID: 19932
		private bool _bFadeAtEnd = true;

		// Token: 0x04004DE0 RID: 19936
		private float farClipPlaneBackUP = 150f;
	}
}
